package com.example.customView;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.viewpageindicator.R;

/**
 * Created by morton on 2015/7/26.
 */
public class TitleBar extends FrameLayout {

    private Button leftButton;

    private TextView titleText;

    public TitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.title_bar, this);

        titleText = (TextView) view.findViewById(R.id.view_title);
        leftButton = (Button) view.findViewById(R.id.btn_finish);
        leftButton.setBackgroundResource(R.drawable.press_finish_btn);

        leftButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity) getContext()).finish();
            }
        });
    }

    public void setTitleText(String text) {
        titleText.setText(text);
    }

    public void setLeftButtonText(String text) {
        leftButton.setText(text);
    }

    public void setLeftButtonListener(OnClickListener l) {
        leftButton.setOnClickListener(l);
    }

}